//
//  SendStatusToolView.swift
//  微博项目
//
//  Created by zhang on 16/3/13.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit

class SendStatusToolView: UIView {

    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
    }
    */
    weak var sendStatusToolViewDelegate:SendStatusToolViewDelegate?
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    convenience init()
    {
        let toolViewH:CGFloat = 44
        self.init(frame: CGRectMake(0, ScreenH - toolViewH, ScreenW, toolViewH))
        let buttonImages = ["compose_camerabutton_background","compose_emoticonbutton_background","compose_keyboardbutton_background","compose_mentionbutton_background","compose_toolbar_picture","compose_trendbutton_background"]
        let buttonW:CGFloat = self.bounds.width / CGFloat(buttonImages.count)
        let buttonH:CGFloat = self.bounds.height
        for var i = 0;i < buttonImages.count;i++
        {
            let button = UIButton(type: UIButtonType.Custom)
            button.tag = i + 1
            button.setImage(UIImage(imageLiteral: buttonImages[i]), forState: UIControlState.Normal)
            button.setImage(UIImage(imageLiteral: "\(buttonImages[i])_highlighted"), forState: UIControlState.Highlighted)
            button.frame = CGRectMake(CGFloat(i) * buttonW, 0, buttonW, buttonH)
            button.addTarget(self, action: Selector("buttonclick:"), forControlEvents: UIControlEvents.TouchDown)
            self.addSubview(button)
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func buttonclick(button:UIButton)
    {
        self.sendStatusToolViewDelegate?.sendStatusToolViewPictureButtonClick?()
    }
}
@objc protocol SendStatusToolViewDelegate
{
    optional func sendStatusToolViewPictureButtonClick()
}
